import requests
import re
from bs4 import BeautifulSoup
if __name__== "__main__":
    headers={
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0'  
    } 
    url='https://link.springer.com/search?new-search=true&query=remote+sensing++OR+RS&sortBy=relevance&content-type=Article&dateFrom&dateTo'
    sp_text=requests.get(url,headers=headers)
    soup=BeautifulSoup(sp_text.text,'lxml')
    soup_t=soup.find_all('h3',class_='app-card-open__heading')
    str_soup_t=str(soup_t)
    str_soup_list=re.findall('href="(.+)">',str_soup_t)
    print(str_soup_list)
    url_2='https://link.springer.com/'+str_soup_list[0]
    soup_t2=requests.get(url_2,headers=headers)
    with open ('.\爬取的文档\论文文档.text','w',encoding='utf-8') as fp :
        print(BeautifulSoup(soup_t2.text).get_text(),file=fp)
